package com.itheima.studentsystem;

import java.util.ArrayList;
import java.util.Random;

public class Test1 {
    public static void main(String[] args) {
        ArrayList<Character> cList = new ArrayList<>();
        //将小写字母放入集合中
        for (int i = 0; i < 26; i++) {
            char c = (char) ('a' + i);
            cList.add(c);
        }
        //将大写字母放入集合中
        for (int i = 0; i < 26; i++) {
            char c = (char) ('A' + i);
            cList.add(c);
        }
        Random r = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            int index = r.nextInt(cList.size());
            char c = cList.get(index);
            sb.append(c);
        }

        int i = r.nextInt(10);
        sb.append(i);
        String str = sb.toString();
        char[] arr = str.toCharArray();
        int index = r.nextInt(arr.length);
        char temp = arr[index];
        arr[index] = arr[arr.length - 1];
        arr[arr.length - 1] = temp;
        String newStr = new String(arr);
        System.out.println(newStr);
    }
}
